/**
 * 
 */
package org.yelongframework.model.support.mybatis.jdbc.executor;

import java.sql.Connection;

import org.yelongframework.core.sql.result.builder.SqlResultBuilder;
import org.yelongframework.core.sql.statement.builder.StatementBuilder;
import org.yelongframework.jdbc.sql.executor.AbstractJdbcSqlExecutor;

/**
 * 使用mybatis原生数据库连接方式实现SQL执行操作，通过sqlSession获取connection对象进行操作，这个不会经过mybatis的框架
 * 
 * @since 1.0.0
 */
public abstract class AbstractMybatisJdbcSqlExecutor extends AbstractJdbcSqlExecutor implements MybatisJdbcSqlExecutor {

	// ==================================================构造器==================================================

	/**
	 * @param statementBuilder 声明构建器
	 * @param sqlResultBuilder SQL结果构建器
	 */
	public AbstractMybatisJdbcSqlExecutor(StatementBuilder statementBuilder, SqlResultBuilder sqlResultBuilder) {
		super(statementBuilder, sqlResultBuilder);
	}

	// ==================================================数据库连接==================================================

	@Override
	public Connection getConnection() {
		try {
			return getSqlSession().getConfiguration().getEnvironment().getDataSource().getConnection();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

}
